/*
 *  $Id: LandCard.cs 1053 2010-05-19 10:05:23Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima {
    /// <summary>
    /// Карта местности
    /// </summary>
    public abstract class LandCard: SummonableCard {
        public LandCard(string id): base(id) {
            LogMessage = Resources.Game.SummonLand;
            Target = JogTarget.Summon;
        }

        public override CardType CardType {
            get { return CardType.Land; }
        }

        public override void DoAction(TargetArgs args) {
            args.Player.SummonLand(this);
        }

        public override CardPlace PlaceAfterUse { get { return CardPlace.None; } }
        public override CardPlace PlaceAfterDeath { get { return CardPlace.Deck2; } }
    }

    /// <summary>
    /// Генерализованная карта местности, приводящая TargetArgs к определенному типу
    /// </summary>
    public abstract class LandCard<T>: LandCard {
        public LandCard(string id): base(id) {}

        public sealed override void ManaCostAction(TargetArgs args, ElementValues manas) {
            if (args is TargetArgs<T>)
                ManaCostAction((TargetArgs<T>) args, manas);
            else
                base.ManaCostAction(args, manas);
        }
        public sealed override bool IsPossibleAction(TargetArgs args) {
            if (args is TargetArgs<T>)
                return IsPossibleAction((TargetArgs<T>) args);
            else
                return base.IsPossibleAction(args);
        }
        public sealed override void LogAction(Log log, TargetArgs args) {
            if (args is TargetArgs<T>)
                LogAction(log, (TargetArgs<T>) args);
            else
                base.LogAction(log, args);
        }
        public sealed override void DoAction(TargetArgs args) {
            if (args is TargetArgs<T>)
                DoAction((TargetArgs<T>) args);
            else
                base.DoAction(args);
        }
        protected virtual void ManaCostAction(TargetArgs<T> args, ElementValues manas) {
            base.ManaCostAction(args, manas);
        }

        protected virtual bool IsPossibleAction(TargetArgs<T> args) {
            return base.IsPossibleAction(args);
        }
        protected virtual void LogAction(Log log, TargetArgs<T> args) {
            base.LogAction(log, args);
        }
        protected virtual void DoAction(TargetArgs<T> args) {
            base.DoAction(args);
        }
    }
}
